<html>
<head><meta charset="utf-8"><title>_ in array type · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html">_ in array type</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197222407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222407">(May 12 2020 at 00:25)</a>:</h4>
<p>Is there any specific reason why _ isn't allowed in array types to infer the length?</p>



<a name="197222429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222429">(May 12 2020 at 00:25)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">];</span><span class="w"> </span><span class="c1">// works</span>
<span class="kd">let</span><span class="w"> </span><span class="n">b</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="n">_</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">];</span><span class="w"> </span><span class="c1">// extremely surprised but this doesn&#39;t work</span>
</code></pre></div>



<a name="197222594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222594">(May 12 2020 at 00:28)</a>:</h4>
<p>today's compiler treats it as a separate inference context, iirc, but I believe lang recently discussed this as part of the _ for array-typed consts rfc and decided that at least for lets it's a 'definitely should work' -- but I may be misrepresenting, and definitely it wasn't full attendance from lang in that meeting</p>



<a name="197222667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222667">(May 12 2020 at 00:29)</a>:</h4>
<p>okay, so presumably this doesn't need an RFC and some sort of pushing for it to eventually be added to the lang, given that other people are already talking about it</p>



<a name="197222740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222740">(May 12 2020 at 00:30)</a>:</h4>
<p>It does need some sort of push.</p>



<a name="197222749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222749">(May 12 2020 at 00:30)</a>:</h4>
<p><a href="https://github.com/rust-lang/rfcs/pull/2545">https://github.com/rust-lang/rfcs/pull/2545</a></p>



<a name="197222764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222764">(May 12 2020 at 00:30)</a>:</h4>
<p>I think for lets though we felt that we could likely land with a PR?</p>



<a name="197222784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222784">(May 12 2020 at 00:30)</a>:</h4>
<p>Maybe I'm misremembering :) </p>
<p>That's definitely <em>my</em> opinion -- I think const items are the harder question</p>



<a name="197222803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222803">(May 12 2020 at 00:31)</a>:</h4>
<p>ooh cool but the rfc is already done</p>



<a name="197222807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222807">(May 12 2020 at 00:31)</a>:</h4>
<p>Oh, <code>let</code>.</p>



<a name="197222817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222817">(May 12 2020 at 00:31)</a>:</h4>
<p>Yeah, it's more obvious for <code>let</code>, since you can already infer the entire type.</p>



<a name="197222820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222820">(May 12 2020 at 00:31)</a>:</h4>
<p>I'm more eager to have it for <code>const</code>, where you <em>have</em> to specify the type.</p>



<a name="197222923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197222923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197222923">(May 12 2020 at 00:33)</a>:</h4>
<p>Yes -- I think consts are not a "no duh" case due to potential interaction with "global inference" and it being perhaps somewhat tough to specify exactly to what extent we avoid that (though maybe not, not sure -- seems like it could be hard but may not be). But <code>let</code> seems to be, IMO there's it's more so "just a bug" in some sense</p>



<a name="197242669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197242669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197242669">(May 12 2020 at 07:51)</a>:</h4>
<p>Also see <a href="https://github.com/rust-lang/rust/issues/70754">https://github.com/rust-lang/rust/issues/70754</a> for the more general case with const generics.</p>



<a name="197456534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/_%20in%20array%20type/near/197456534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/_.20in.20array.20type.html#197456534">(May 13 2020 at 18:33)</a>:</h4>
<p>Last this came up in a meeting I think we said that for <code>let</code>s in particular, this (or something very similar) is expected to happen as part of the const generics work, but that we wouldn't push for specific situations of it before then.</p>
<p>But thanks for the reminder, I forgot to do a follow-up from a previous design meeting about <code>const</code>s...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>